package org.example.cicdi.service.impl.third;

import org.example.cicdi.service.impl.ext.FieldAnnotationServiceExt;
import org.example.cicdi.service.impl.org.TableAnnotationService;
import org.example.cicdi.service.impl.second.FieldfacaService;
import org.example.cicdi.service.impl.second.TbfacaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Configuration
@EnableConfigurationProperties(StarterCodeServiceProperties.class)
@ConditionalOnClass(StarterServiceAutoConfiguration.class)
public class StarterServiceAutoConfiguration {
    @Autowired
    private List<TableAnnotationService> tableServices;
    @Autowired
    private List<FieldAnnotationServiceExt>fieldServices;
    @Autowired
    private TbfacaService tbfacaService;
    @Autowired
    private FieldfacaService fieldfacaService;

    @Autowired
    private StarterCodeServiceProperties serviceProperties;
    @Bean
    public StarterCodeServiceExtSecond starterService() {
        StarterCodeServiceExtSecond starterCodeService = new StarterCodeServiceExtSecond();
        starterCodeService.setTableServices(tableServices);
        starterCodeService.setFieldServices(fieldServices);
        starterCodeService.setTbfacaService(tbfacaService);
        starterCodeService.setFieldfacaService(fieldfacaService);

        starterCodeService.setIncludedeployway(serviceProperties.getIncludedeployway());
        starterCodeService.setBASE_PACKAGE(serviceProperties.getBasepackage());
        starterCodeService.setJpaserverurl(serviceProperties.getJpaserverurl());
        return starterCodeService;
    }
}
